<template>
  <div id="banner">
    <el-carousel height="400px">
      <el-carousel-item id="el-carousel-item" v-for="item in banner_list">
<!--        <img src="../assets/img/banner1.png" alt="">-->
        <router-link :to=item.link>
          <img :src="item.img" :alt="item.name">
        </router-link>

      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "Banner",
  data() {
    return {
      banner_list: []
    }
  },
  created() {
    //当banner组件一创建，就向后台发请求，拿轮播图数据
    this.$axios.get(this.$settings.base_url + '/home/banner/').then(response => {
      this.banner_list = response.data
    }).catch(error => {
    })
  },

}
</script>

<style scoped>
#el-carousel-item {
  height: 400px;
  min-width: 1200px;
}

#el-carousel-item img {
  height: 400px;
  margin-left: calc(50% - 1920px / 2);

}

</style>